<template>
  <div class="main_box">
    <router-link to="/control/login/login">
      <mt-button icon="back">个人中心</mt-button>
    </router-link>
    <input type="text" class="username" placeholder="QQ/邮箱/手机号" v-model="name" />
    <input type="password" class="userpass" placeholder="密码" v-model="password" />
    <button class="login" @click="login">登录</button>
    <div class="register">
      <router-link to="/user/register" tag="span">忘记密码</router-link>
      <span>|</span>
      <router-link to="/control/login/forget_pwd" tag="span">用户注册</router-link>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      name: "",
      password: ""
    };
  },
  methods: {
    login() {
      let data = new FormData();
      data.append("name", this.name);
      data.append("password", this.password);
      this.axios
        .post("http://127.0.0.1/homework/my-ying/php/login.php", data)
        .then(res => {
          var img = res.data[0].img;
          if (res.data[0].name == this.name) {
            document.cookie = "name=" + this.name;
            document.cookie = "img=" + img;
            location.href = "#/control/login/login";
            
          } else {
            alert("您的账号或密码不正确");
          }
        });
    }
  }
};
</script>
<style scoped>
.mint-button--default {
  background-color: rgba(255, 0, 0, 0);
}
.tip {
  text-align: center;
  color: black;
}
.logo {
  display: block;
  margin: 20px auto;
  border-radius: 8px;
}
.main_box {
  width: 100%;
  padding-bottom: 60px;
  height: 100%;
}
.main_box.box {
  padding-left: 20px;
  padding-right: 20px;
  background: white;
}
.main_box > input {
  border: none;
  border-bottom: 1px solid rgb(98, 98, 98);
  margin-top: 5px;
  border-radius: 0px;
}
.main_box > button {
  display: block;
  border-radius: 6px;
  width: 100%;
  margin-top: 20px;
  height: 38px;
}
.main_box .login {
  border: none;
  height: 40px;
  background-color: rgb(255, 123, 0);
  color: white;
  font-size: 18px;
  font-family: "楷体";
}
.main_box .login_by_msg {
  border: 1px solid rgb(255, 123, 0);
  height: 38px;
  color: rgb(255, 123, 0);
  font-size: 18px;
  font-family: "楷体";
}
.register {
  width: 100%;
  text-align: center;
  height: 44px;
  line-height: 44px;
  font-size: 16px;
  color: #626262;
}
.login_by_other {
  font-size: 14px;
  color: #626262;
  text-align: center;
}
.other_method {
  display: block;
  margin: 0 auto;
}
.language {
  text-align: center;
  margin-top: 10px;
}
.language > span {
  font-size: 14px;
  color: #909090;
  margin: 0px 4px;
}
.language > .active {
  color: red;
}
</style>

